package com.aliyun.messagemgt.common.dto.foura;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class FourAAuthorityVo implements Serializable{

	private static final long serialVersionUID = 5485848225233751408L;
	
	private String key;
	
	private String name;
	
	private String parent;
	
	private String url;
	
	private int order = 0;
	
	private List<FourAAuthorityVo> children;
	
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getParent() {
		return parent;
	}
	public void setParent(String parent) {
		this.parent = parent;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public List<FourAAuthorityVo> getChildren() {
		return children;
	}
	public void setChildren(List<FourAAuthorityVo> children) {
		this.children = children;
	}
	
    public void addChild(FourAAuthorityVo child) {
        if (children == null) {
            children = new LinkedList<>();
        }
        boolean bool = false;
        ListIterator<FourAAuthorityVo> itr = children.listIterator();
        while (itr.hasNext()) {
        	FourAAuthorityVo vo = itr.next();
            if (vo.getOrder() > child.getOrder()) {
                bool = true;
                itr.add(child);
                break;
            }
        }
        if (!bool) {
            children.add(child);
        }
        child.setParent(getKey());
    }
	public int getOrder() {
		return order;
	}
	public void setOrder(int order) {
		this.order = order;
	}

}
